まずは,
Se (\(y_i - \hat{y} \)の平方和)
を計算してみましょう.
a0, a1, を未知数として推定した結果は,ここから,
\(\Large\displaystyle \hat{a_1} = \frac{ \overline{x y} - \bar{x} \bar{y} }
{ \displaystyle
\overline{x^2}- \bar{x}^2}
\)
\(\Large\displaystyle \hat{a_0} = \bar{y} - \frac{ \overline{x y} - \bar{x} \bar{y} }
{ \displaystyle
\overline{x^2}- \bar{x}^2}
\bar{x}
= \bar{y} -\hat{a_1}
\bar{x} \)
となります.ここから,
\(\Large \displaystyle Se = \sum_{i=1}^{n} \left( y_i -\hat{a_0} - \hat{a_1} x_i \right)^2 \)
ですので,
\(\Large \displaystyle = \sum_{i=1}^{n} y_i^2 +\sum_{i=1}^{n} \hat{a_0}^2 + \sum_{i=1}^{n} \left( \hat{a_1} x_i \right)^2
-2 \sum_{i=1}^{n}
\hat{a_0} y_i - 2 \sum_{i=1}^{n} \hat{a_1} x_i y_i +2 \sum_{i=1}^{n} \hat{a_0} \hat{a_1} x_i \)
\(\Large \displaystyle = n \bar{y^2} +n \hat{a_0}^2 + n \hat{a_1}^2 \bar{x}^2
-2
n \hat{a_0} \bar{y} - 2 n \hat{a_1} \overline{x y} +2 n \hat{a_0} \hat{a_1} \bar{x} \)
ここで,\(\Large\displaystyle \hat{a_0} = \bar{y} -\hat{a_1} \bar{x} \),を代入して,
\(\Large \displaystyle = n \left[ \bar{y^2} + ( \bar{y} -\hat{a_1}
\bar{x})^2 + \hat{a_1}^2 \bar{x}^2
-2 ( \bar{y} -\hat{a_1}
\bar{x}) \bar{y} - 2 \hat{a_1} \overline{x y} +2 ( \bar{y} -\hat{a_1}
\bar{x}) \hat{a_1} \bar{x} \right]\)
\(\Large \displaystyle = n [ \bar{y^2} + \bar{y}^2 - 2\hat{a_1} \bar{x} \bar{y} + \hat{a_1}^2 \bar{x}^2+ \hat{a_1}^2 \bar{x^2} \)
\(\Large \displaystyle \hspace{30 pt} -2 \bar{y}^2 - 2 \hat{a_1} \bar{x} \bar{y} - 2 \hat{a_1} \overline{x y} +2 \hat{a_1} \bar{x} \bar{y} - 2\hat{a_1}^2 \bar{x}^2 ]\)
となります.同じ項目を色分けすると,
\(\Large \displaystyle = n [ \bar{y^2} + \color{blue}{\bar{y}^2} \color{red}{- 2\hat{a_1} \bar{x} \bar{y}} \color{purple}{+ \hat{a_1}^2 \bar{x}^2}+ \hat{a_1}^2 \bar{x^2} \)
\(\Large \displaystyle \hspace{30 pt} \color{blue}{-2 \bar{y}^2} \color{red}{- 2 \hat{a_1} \bar{x} \bar{y}} - 2 \hat{a_1} \overline{x y} \color{red}{+2 \hat{a_1} \bar{x} \bar{y}} \color{purple}{- 2\hat{a_1}^2 \bar{x}^2} ]\)
となるので,整理すると,
\(\Large \displaystyle = n [ \bar{y^2} - \bar{y}^2 + 2\hat{a_1} \bar{x} \bar{y} + \hat{a_1}^2 \bar{x^2}- 2 \hat{a_1} \overline{x y} - \hat{a_1}^2 \bar{x}^2 ]\)
\(\Large \displaystyle = n [ \bar{y^2} - \bar{y}^2 - 2\hat{a_1} (\bar{x} \bar{y} - \overline{x y}) + \hat{a_1}^2 (\bar{x^2}- \bar{x}^2) ]\)
ここで,\(\Large\displaystyle \hat{a_1} = \frac{ \overline{x y} - \bar{x} \bar{y} }
{ \displaystyle
\overline{x^2}- \bar{x}^2}
\),を代入すると,
\(\Large \displaystyle = n \left[ \bar{y^2} - \bar{y}^2
- 2 \frac{ \overline{x y} - \bar{x} \bar{y} }
{ \displaystyle
\overline{x^2}- \bar{x}^2} (\bar{x} \bar{y} - \overline{x y})
+ \left( \frac{ \overline{x y} - \bar{x} \bar{y} }
{ \displaystyle
\overline{x^2}- \bar{x}^2} \right)^2 (\bar{x^2}-
\bar{x}^2) \right] \)
\(\Large \displaystyle = n \left[ \bar{y^2} - \bar{y}^2
- 2 \frac{ (\overline{x y} - \bar{x} \bar{y})^2 }
{ \displaystyle
\overline{x^2}- \bar{x}^2}
+ \frac{ ( \overline{x y} - \bar{x} \bar{y})^2 }
{ \displaystyle
\overline{x^2}- \bar{x}^2} \right] \)
\(\Large \displaystyle = n \left[ \bar{y^2} - \bar{y}^2
- \frac{ (\overline{x y} - \bar{x} \bar{y})^2 }
{ \displaystyle
\overline{x^2}- \bar{x}^2} \right] \)
となります.